package com.loup.registory;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Created by loup on 2018/4/26.
 */
public class MapperRegistory<T> {

    public static Map<String,MapperData> methodSqlMappering = new ConcurrentHashMap<String, MapperData>();


    /**
     *
     * @param methodPath 方法的全路径名
     * @param sql 要执行的sql
     * @param returnType 返回值类型
     */
    public void addMapper(String methodPath, String sql, Class<T> returnType){
        methodSqlMappering.put(methodPath,new MapperData(sql,returnType));
    }

    public static MapperData getMapperData(String methodPath){
        return methodSqlMappering.get(methodPath);
    }


    public static class MapperData<T> {
        private String sql;
        private Class<T> returnType;

        public MapperData(String sql,Class<T> returnType){
            this.sql = sql;
            this.returnType = returnType;
        }

        public String getSql() {
            return sql;
        }

        public void setSql(String sql) {
            this.sql = sql;
        }

        public Class<T> getReturnType() {
            return returnType;
        }

        public void setReturnType(Class<T> returnType) {
            this.returnType = returnType;
        }
    }

}
